#include <app\states\moveState.h>
#include <app\states\statesFactory.h>

int moveState::class_type_id = MOVE_STATE_TYPE_ID;

REGISTER_STATE(MOVE_STATE_TYPE_ID, moveState);

sessionState *
moveState::create() {
  return new moveState();
} 

void 
moveState::pickSharedPosition() {
  shared_position = new_position;
}

vec3f 
moveState::getSharedPosition() {
  return shared_position;
}

void 
moveState::setStartPosition(vec3f start_position_) {
  start_position = start_position_;
}

vec3f 
moveState::getStartPosition() {
  return start_position;
}

vec3f 
moveState::getCurrentPosition() {
  return new_position;
}

void 
moveState::move(const float x, const float y, const float z) {
  new_position = vec3f(x, y, z);
  moved = (new_position != shared_position);

  //std::cout << "move: " << x << " " << y << " " << z << endl;
  if (moved) move_sig(x, y, z);
}

void 
moveState::addMoveObserver(moveObserver *ref) {
  move_sig.connect(boost::bind(&moveObserver::move, ref, _1 , _2, _3));
}

int
moveState::getClassTypeId() {
  return moveState::class_type_id;
}

int
moveState::getTypeId() {
  return type_id;
}

moveState::moveState() : type_id(MOVE_STATE_TYPE_ID), moved(false) {

}

moveState::~moveState() {

}